home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / DEBUG / BPTRAP10 / README.TXT < prev    next >
Text File  |  1996-02-29  |  5KB  |  117 lines

  1. BPTRAP 1.0
  2. ==========
  3.  
  4. Copyright (C) 1996 Frank Heckenbach
  5.  
  6. DESCRIPTION:
  7. ------------
  8. The Unit BPTrap allows you to trap runtime errors in a Borland Pascal
  9. program. That means, a runtime error will not abort the program but pass
  10. the control back to a point within the program.
  11.  
  12. It should run with Borland Pascal 7.0 on all three platforms (Real mode,
  13. Protected mode and Windoze).
  14.  
  15. The Usage is simple. See the TrapDemo program:
  16.  
  17. Calling the Trap procedure will install Trap and return the value False.
  18.  
  19. Whenever a runtime error occurs after installing Trap, the program will be
  20. continued at the point from which Trap was installed! This means, the program
  21. will JUMP BACK (and thereby cause a loop - without a For, While or Repeat
  22. statement in your program)! To differentiate this from the installation call,
  23. now the value True is "returned". By testing the return value, a loop can be
  24. avoided (see the TrapDemo program), but sometimes the loop is what is wanted.
  25.  
  26. You can uninstall Trap by calling UnTrap. This function will return True
  27. iff it could uninstall Trap. If it could not, reasons may be that Trap was
  28. not installed or that other Exitprocs were installed after Trap.
  29.  
  30. When the program terminates (by reaching the end or by a Halt or Keep
  31. statement) and a runtime error was trapped during the run, Trap will set the
  32. Exitcode and Erroraddr variables to indicate the trapped error. So the
  33. program will display a "correct" runtime error message (even if it has kept
  34. running for a while after the trapped error!). One advantage of this is that
  35. if you are using the integrated debugger (real mode), it will show you the
  36. error position in your source code as usual.
  37.  
  38. If you have any hints, suggestions or error reports (apart from runtime
  39. errors trapped by my unit ;-), I will be interested to hear from you.
  40.  
  41. CAUTIONS:
  42. ---------
  43. * The procedure that calls Trap must NOT return as long as Trap is installed
  44.   (so it is safest to call Trap from the main program, if possible)!
  45.  
  46. * You must call the function Trap AFTER installing all other Exitprocs
  47.   (if any).
  48.  
  49. * In Real mode: You must NOT call it from an overlayed unit.
  50.  
  51. * In Protected mode and Windoze: You must call it from a code segment with
  52.   the following attributes: FIXED PRELOAD PERMANENT. (I am not sure if this
  53.   is really necessary...).
  54.  
  55. * After trapping a runtime error, your program might not be is a stable state.
  56.   If the runtime error was a "minor" one (such as a range checking or
  57.   arithmetic error) and if the other cautions have been respected, it should
  58.   not be a problem. But if you e.g. write a larger application and use trap
  59.   to prevent a sudden abort, you should make the program terminate regularly
  60.   as soon as possible after a trapped error (maybe telling the user to
  61.   terminate the program and report the error to you).
  62.  
  63. * Since the exit proc JUMPS back, it has all the negative effects that a GOTO
  64.   would have! (And even a global GOTO!) You should be aware of the
  65.   consequences of all active procedures being terminated at some point!
  66.  
  67. * The program has been tested with BP version 7.0 only. It may well work with
  68.   other BP versions, but you will have to try that on your own risk.
  69.   As a safety measure, I inserted two lines that will prevent the unit from
  70.   compiling with any BP version different from 7.0. To still do that, you
  71.   have to delete or comment these two lines.
  72.  
  73. * The program has been tested mainly in real mode, so if you want to use it
  74.   seriously on another platform (Protected mode or Windoze), you should test
  75.   it more thoroughly.
  76.  
  77. FILES:
  78. ------
  79. The package consists of the following files:
  80.  
  81. README.TXT     This file
  82. COPYING        The Gnu General Public License
  83. BPTRAP.PAS     The Trap unit
  84. TRAPDEMO.PAS   A simple demo program using the Trap unit, working on all
  85.                three platforms
  86.  
  87. LEGAL STUFF:
  88. ------------
  89. The Trap unit and the Trap demo program (both below referred to as
  90. "the program") are Copyright (C) 1996 Frank Heckenbach.
  91.  
  92. This program is free software; you can redistribute it and/or modify
  93. it under the terms of the GNU General Public License as published by
  94. the Free Software Foundation, version 1, for NON-COMMERCIAL use.
  95.  
  96. This program is distributed in the hope that it will be useful,
  97. but WITHOUT ANY WARRANTY; without even the implied warranty of
  98. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  99. GNU General Public License for more details.
  100.  
  101. You should have received a copy of the GNU General Public License
  102. along with this program; if not, write to the Free Software
  103. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  104.  
  105. For using this program commercially in any way, the GNU General
  106. Public License is NOT applicable. Any commercial use of the program
  107. must be explicitly allowed by the author and will usually require
  108. payment of a royalty.
  109.  
  110. Borland Pascal is a registered trademark of Borland International, Inc.
  111.  
  112. Windoze is not a trademark ;-)
  113.  
  114. Frank Heckenbach
  115. Email: heckenb@mi.uni-erlangen.de
  116.        alternatively: fn106@fim.uni-erlangen.de
  117.